<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ITEM - 添加选择题</title>
    <script type="text/javascript" src="../static/js/vue-2.5.16.js"></script>
    <script src="{{ static('js/jwt.js') }}"></script>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="{{ static('css/bootstrap.min.css') }}" rel="stylesheet">
    <link href="{{ static('css/font-awesome.min.css') }}" rel="stylesheet">
    <link href="{{ static('css/animate.min.css') }}" rel="stylesheet">
    <link href="{{ static('css/style.min.css') }}" rel="stylesheet">
    <script src="{{ static('js/jquery.min.js') }}"></script>
    <script type="text/javascript" language="javascript">
        /*------判断radio是否有选中，获取选中的值--------*/
        $(function () {
            $("#btnSubmit").click(function () {
                var val = $('input:radio[name="answer"]:checked').val();
                if (val == null) {
                    alert("你什么也没选中!请选择一个答案");
                    return false;
                } else {
                    {#alert(val);#}

                }
                var list = $('input:radio[name="list"]:checked').val();
                if (list == null) {
                    alert("请选择一个难度");
                    return false;
                } else {
                    {#alert(list);#}
                }
            });
        });
    </script>
    <base target="_blank">

</head>

<body class="gray-bg">


<div class="ibox-content">
    <form method="post" class="form-horizontal">
        <div class="form-group">
            <label class="col-sm-2 control-label">题目</label>
            <div class="col-sm-10">
                <textarea class="area form-control" id="item" rows="5" placeholder="请输入题目内容"></textarea>
                <span class="text-count">150</span>/150
            </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">答案</label>
            <div class="col-sm-10">
                <input type="radio" name="answer" checked value="正确"/>正确
                <input type="radio" name="answer" value="错误"/>错误

            </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">解析</label>
            <div class="col-sm-10">
                <textarea class="area2 form-control" id="analysis" placeholder="请输入题目解析"></textarea>
                <span class="text-count2">150</span>/150 
            </div>
        </div>
        <!--        <div class="form-group">-->
        <!--            <label class="col-sm-2 control-label">带说明信息</label>-->
        <!--            <div class="col-sm-10">-->
        <!--                <input type="text" class="form-control"> <span class="help-block m-b-none">帮助文本，可能会超过一行，以块级元素显示</span>-->
        <!--            </div>-->
        <!--        </div>-->
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <label class="col-sm-2 control-label">难度</label>
            <div class="col-sm-10">
                <input type="radio" name="list" checked value="简单"/>简单
                <input type="radio" name="list" value="一般"/>满意
                <input type="radio" name="list" value="困难"/>困难
                <input type="radio" name="list" value="比赛级"/>比赛级
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">题目标签</label>
            <div class="col-sm-10">
                {% for i in label %}
                    <input type="checkbox" value="option1" name="test" id="inlineCheckbox1"
                           onclick="fnAlert({{ i.id }})">
                    {{ i.name }}
                {% endfor %}
            </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-2">
                <a type="submit" class="submitBtn btn btn-info btn-rounded" style="margin-left:2.5cm;margin-top: 1cm;"
                   onclick="form_add_true()" id="btnSubmit">确认提交</a>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    /*字数限制*/
    $(".area").on("input propertychange", function () {
        var $this = $(this),
            _val = $this.val(),
            count = "";
        if (_val.length > 150) {
            $this.val(_val.substring(0, 150));
        }
        count = 150 - $this.val().length;
        $(".text-count").text(count);
    });
    $(".area2").on("input propertychange", function () {
        var $this = $(this),
            _val = $this.val(),
            count = "";
        if (_val.length > 150) {
            $this.val(_val.substring(0, 150));
        }
        count = 150 - $this.val().length;
        $(".text-count2").text(count);
    });
</script>
 
<script type="text/javascript">
    function fnAlert(a) {


        var params = {
            "id": a
        };
        $.ajax({
            url: "/add/checked/",
            type: "post",
            // data: params,
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.code == "0") {
                    // 刷新当前界面
                } else {
                    alert(resp.errmsg);
                }
            }
        })
    }

</script>

<script sr  c="{{ static('js/bootstrap.min.js') }}"></script>
<script src="{{ static('js/content.min.js') }}"></script>
</body>

</html>